import React, { Component } from "react";
import styles from "./AddApi.less";

class AddApi extends Component {
  renderApiMethod = type => {
    if (type === "1") {
      return "POST";
    }
    return "GET";
  };

  render() {
    const { dataDetail = {} } = this.props;
    return (
      <div className={styles.root}>
        <div className={styles.basicInfo}>
          <div style={{ display: "flex", justifyContent: "space-between" }}>
            <span className={styles.title}>数据配置</span>
          </div>
          <div className={styles.line}>
            <div className={styles.onePiece}>
              URL：
              <span className={styles.content}>
                {dataDetail.apiUrl || `暂无`}
              </span>
            </div>
            <div className={styles.onePiece}>
              host：
              <span className={styles.content}>
                {dataDetail.apiHost || `暂无`}
              </span>
            </div>
          </div>
          <div className={styles.line}>
            <div className={styles.onePiece}>
              app_key：
              <span className={styles.content}>
                {dataDetail.apiAppKey || `暂无`}
              </span>
            </div>
            <div className={styles.onePiece}>
              app_secret：
              <span className={styles.content}>
                {dataDetail.apiAppSecret || `暂无`}
              </span>
            </div>
          </div>
          <div className={styles.line}>
            <div className={styles.onePiece}>
              method：
              <span className={styles.content}>
                {dataDetail.apiMethod
                  ? this.renderApiMethod(dataDetail.apiMethod)
                  : `暂无`}
              </span>
            </div>
          </div>
        </div>
      </div>
    );
  }
}

export default AddApi;
